package com.yanqingying.service.impl;

import com.yanqingying.ClazzCountOption;
import com.yanqingying.JobOption;
import com.yanqingying.mapper.EmpMapper;
import com.yanqingying.mapper.StudentMapper;
import com.yanqingying.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    EmpMapper empMapper;
    @Autowired
    StudentMapper studentMapper;
    @Override
    public List<Map> empGenderData() {
        return empMapper.empGenderData();
    }

    @Override
    public JobOption empJobData() {
        List<Map> list = empMapper.empJobData();
        List jobList = list.stream().map(item -> item.get("pos")).toList();
        List dataList =list.stream().map(item -> item.get("sum")).toList();
        return new JobOption(jobList,dataList);
    }

    @Override
    public List<Map> studentDegreeData() {
        return studentMapper.studentDegreeData();
    }

    @Override
    public ClazzCountOption studentCountData() {
        List<Map> mapList = studentMapper.studentCountData();
        List clazzList = mapList.stream().map(item -> item.get("clazzList")).toList();
        List dataList   = mapList.stream().map(item -> item.get("dataList")).toList();
        return new ClazzCountOption(clazzList,dataList);
    }
}
